<!DOCTYPE html>
<html>
  <head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8">
  <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
  <meta name="description" content="刘清政">
  <meta name="keyword" content="hexo-theme">
  
    <link rel="shortcut icon" href="/css/images/logo.png">
  
  <title>
    
      python/路飞项目/1-项目基础/15-跨域请求详解 | Justin-刘清政的博客
    
  </title>
  <link href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
  <link href="//cdnjs.cloudflare.com/ajax/libs/nprogress/0.2.0/nprogress.min.css" rel="stylesheet">
  <link href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/tomorrow.min.css" rel="stylesheet">
  
<link rel="stylesheet" href="/css/style.css">

  
    
<link rel="stylesheet" href="/css/plugins/gitment.css">

  
  <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  <script src="//cdnjs.cloudflare.com/ajax/libs/geopattern/1.2.3/js/geopattern.min.js"></script>
  <script src="//cdnjs.cloudflare.com/ajax/libs/nprogress/0.2.0/nprogress.min.js"></script>
  
    
<script src="/js/qrious.js"></script>

  
  
    
<script src="/js/gitment.js"></script>

  
  

  
<meta name="generator" content="Hexo 4.2.0"></head>
<div class="wechat-share">
  <img src="/css/images/logo.png" />
</div>

  <body>
    <header class="header fixed-header">
  <div class="header-container">
    <a class="home-link" href="/">
      <div class="logo"></div>
      <span>Justin-刘清政的博客</span>
    </a>
    <ul class="right-list">
      
        <li class="list-item">
          
            <a href="/" class="item-link">主页</a>
          
        </li>
      
        <li class="list-item">
          
            <a href="/tags/" class="item-link">标签</a>
          
        </li>
      
        <li class="list-item">
          
            <a href="/archives/" class="item-link">归档</a>
          
        </li>
      
        <li class="list-item">
          
            <a href="/about/" class="item-link">关于我</a>
          
        </li>
      
    </ul>
    <div class="menu">
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
    </div>
    <div class="menu-mask">
      <ul class="menu-list">
        
          <li class="menu-item">
            
              <a href="/" class="menu-link">主页</a>
            
          </li>
        
          <li class="menu-item">
            
              <a href="/tags/" class="menu-link">标签</a>
            
          </li>
        
          <li class="menu-item">
            
              <a href="/archives/" class="menu-link">归档</a>
            
          </li>
        
          <li class="menu-item">
            
              <a href="/about/" class="menu-link">关于我</a>
            
          </li>
        
      </ul>
    </div>
  </div>
</header>

    <div id="article-banner">
  <h2>python/路飞项目/1-项目基础/15-跨域请求详解</h2>



  <p class="post-date">2020-07-16</p>
    <!-- 不蒜子统计 -->
    <span id="busuanzi_container_page_pv" style='display:none' class="">
        <i class="icon-smile icon"></i> 阅读数：<span id="busuanzi_value_page_pv"></span>次
    </span>
  <div class="arrow-down">
    <a href="javascript:;"></a>
  </div>
</div>
<main class="app-body flex-box">
  <!-- Article START -->
  <article class="post-article">
    <section class="markdown-content"><h1 id="跨域请求"><a href="#跨域请求" class="headerlink" title="跨域请求"></a>跨域请求</h1><h2 id="一-同源策略"><a href="#一-同源策略" class="headerlink" title="一 同源策略"></a>一 同源策略</h2><p>同源策略（Same origin policy）是一种约定，它是浏览器最核心也最基本的安全功能，如果缺少了同源策略，则浏览器的正常功能可能都会受到影响。可以说Web是构建在同源策略基础之上的，浏览器只是针对同源策略的一种实现</p>
<p>请求的url地址,必须与浏览器上的url地址处于同域上,也就是域名,端口,协议相同.</p>
<p>比如:我在本地上的域名是127.0.0.1:8000,请求另外一个域名：127.0.0.1:8001一段数据</p>
<p>浏览器上就会报错，个就是同源策略的保护,如果浏览器对javascript没有同源策略的保护,那么一些重要的机密网站将会很危险</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">已拦截跨源请求：同源策略禁止读取位于 http:&#x2F;&#x2F;127.0.0.1:8001&#x2F;SendAjax&#x2F; 的远程资源。（原因：CORS 头缺少 &#39;Access-Control-Allow-Origin&#39;）。</span><br></pre></td></tr></table></figure>



<p>但是注意，项目2中的访问已经发生了，说明是浏览器对非同源请求返回的结果做了拦截</p>
<h2 id="二-CORS（跨域资源共享）简介"><a href="#二-CORS（跨域资源共享）简介" class="headerlink" title="二 CORS（跨域资源共享）简介"></a>二 CORS（跨域资源共享）简介</h2><p>CORS需要浏览器和服务器同时支持。目前，所有浏览器都支持该功能，IE浏览器不能低于IE10。</p>
<p>整个CORS通信过程，都是浏览器自动完成，不需要用户参与。对于开发者来说，CORS通信与同源的AJAX通信没有差别，代码完全一样。浏览器一旦发现AJAX请求跨源，就会自动添加一些附加的头信息，有时还会多出一次附加的请求，但用户不会有感觉。</p>
<p>因此，实现CORS通信的关键是服务器。只要服务器实现了CORS接口，就可以跨源通信。</p>
<h2 id="三-CORS基本流程"><a href="#三-CORS基本流程" class="headerlink" title="三 CORS基本流程"></a>三 CORS基本流程</h2><p>浏览器将CORS请求分成两类：<strong>简单请求（simple request）</strong>和<strong>非简单请求（not-so-simple request</strong>）。<br>浏览器发出CORS<strong>简单请求</strong>，<strong>只需要在头信息之中增加一个Origin字</strong>段。<br>浏览器发出CORS<strong>非简单请求</strong>，<strong>会在正式通信之前，增加一次HTTP查询请求，称为”预检”请求（preflight）。浏览器先询问服务器，当前网页所在的域名是否在服务器的许可名单之中，以及可以使用哪些HTTP动词和头信息字段。只有得到肯定答复，浏览器才会发出正式的XMLHttpRequest请求，否则就报错。</strong></p>
<h2 id="四-CORS两种请求详解"><a href="#四-CORS两种请求详解" class="headerlink" title="四 CORS两种请求详解"></a>四 CORS两种请求详解</h2><p>只要同时满足以下两大条件，就属于简单请求。</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">（<span class="number">1</span>) 请求方法是以下三种方法之一：</span><br><span class="line">HEAD</span><br><span class="line">GET</span><br><span class="line">POST</span><br><span class="line">（<span class="number">2</span>）HTTP的头信息不超出以下几种字段：</span><br><span class="line">Accept</span><br><span class="line">Accept-Language</span><br><span class="line">Content-Language</span><br><span class="line">Last-Event-ID</span><br><span class="line">Content-Type：只限于三个值application/x-www-form-urlencoded、multipart/form-data、text/plain</span><br></pre></td></tr></table></figure>

<p>凡是不同时满足上面两个条件，就属于非简单请求。</p>
<p>浏览器对这两种请求的处理，是不一样的。</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">* 简单请求和非简单请求的区别？</span><br><span class="line"></span><br><span class="line">   简单请求：一次请求</span><br><span class="line">   非简单请求：两次请求，在发送数据之前会先发一次请求用于做“预检”，只有“预检”通过后才再发送一次请求用于数据传输。</span><br><span class="line">* 关于“预检”</span><br><span class="line"></span><br><span class="line">- 请求方式：OPTIONS</span><br><span class="line">- “预检”其实做检查，检查如果通过则允许传输数据，检查不通过则不再发送真正想要发送的消息</span><br><span class="line">- 如何“预检”</span><br><span class="line">     =&gt; 如果复杂请求是PUT等请求，则服务端需要设置允许某请求，否则“预检”不通过</span><br><span class="line">        Access-Control-Request-Method</span><br><span class="line">     =&gt; 如果复杂请求设置了请求头，则服务端需要设置允许某请求头，否则“预检”不通过</span><br><span class="line">        Access-Control-Request-Headers</span><br></pre></td></tr></table></figure>

<p><strong>支持跨域，简单请求</strong></p>
<p>服务器设置响应头：Access-Control-Allow-Origin = ‘域名’ 或 ‘*’</p>
<p><strong>支持跨域，复杂请求</strong></p>
<p>由于复杂请求时，首先会发送“预检”请求，如果“预检”成功，则发送真实数据。</p>
<ul>
<li>“预检”请求时，允许请求方式则需服务器设置响应头：Access-Control-Request-Method</li>
<li>“预检”请求时，允许请求头则需服务器设置响应头：Access-Control-Request-Headers</li>
</ul>
<h2 id="五-Django项目中支持CORS"><a href="#五-Django项目中支持CORS" class="headerlink" title="五 Django项目中支持CORS"></a>五 Django项目中支持CORS</h2><p> 在返回的结果中加入允许信息（简单请求）</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">test</span><span class="params">(request)</span>:</span></span><br><span class="line">    <span class="keyword">import</span> json</span><br><span class="line">    obj=HttpResponse(json.dumps(&#123;<span class="string">'name'</span>:<span class="string">'lqz'</span>&#125;))</span><br><span class="line">    <span class="comment"># obj['Access-Control-Allow-Origin']='*'</span></span><br><span class="line">    obj[<span class="string">'Access-Control-Allow-Origin'</span>]=<span class="string">'http://127.0.0.1:8004'</span></span><br><span class="line">    <span class="keyword">return</span> obj</span><br></pre></td></tr></table></figure>

<p> 放到中间件处理复杂和简单请求：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">from</span> django.utils.deprecation <span class="keyword">import</span> MiddlewareMixin</span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">CorsMiddleWare</span><span class="params">(MiddlewareMixin)</span>:</span></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">process_response</span><span class="params">(self,request,response)</span>:</span></span><br><span class="line">        <span class="keyword">if</span> request.method==<span class="string">"OPTIONS"</span>:</span><br><span class="line">            <span class="comment">#可以加*</span></span><br><span class="line">            response[<span class="string">"Access-Control-Allow-Headers"</span>]=<span class="string">"Content-Type"</span></span><br><span class="line">        response[<span class="string">"Access-Control-Allow-Origin"</span>] = <span class="string">"http://localhost:8080"</span></span><br><span class="line">        <span class="keyword">return</span> response</span><br></pre></td></tr></table></figure>

<h2 id="六-django-使用django-cors-headers-解决跨域问题"><a href="#六-django-使用django-cors-headers-解决跨域问题" class="headerlink" title="六 django 使用django-cors-headers 解决跨域问题"></a>六 django 使用django-cors-headers 解决跨域问题</h2><h3 id="1、使用pip安装"><a href="#1、使用pip安装" class="headerlink" title="1、使用pip安装"></a>1、使用pip安装</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">pip install django-cors-headers</span><br></pre></td></tr></table></figure>

<h3 id="2、添加到setting的app中"><a href="#2、添加到setting的app中" class="headerlink" title="2、添加到setting的app中"></a>2、添加到setting的app中</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">INSTALLED_APPS &#x3D; (</span><br><span class="line">	...</span><br><span class="line">	&#39;corsheaders&#39;,</span><br><span class="line">	...</span><br><span class="line">)</span><br></pre></td></tr></table></figure>

<h3 id="3、添加中间件"><a href="#3、添加中间件" class="headerlink" title="3、添加中间件"></a>3、添加中间件</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">MIDDLEWARE &#x3D; [  # Or MIDDLEWARE_CLASSES on Django &lt; 1.10</span><br><span class="line">	...</span><br><span class="line">	&#39;corsheaders.middleware.CorsMiddleware&#39;,</span><br><span class="line">	&#39;django.middleware.common.CommonMiddleware&#39;,</span><br><span class="line">	...</span><br><span class="line">]</span><br></pre></td></tr></table></figure>

<h3 id="4、setting下面添加下面的配置"><a href="#4、setting下面添加下面的配置" class="headerlink" title="4、setting下面添加下面的配置"></a>4、setting下面添加下面的配置</h3><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><span class="line">CORS_ALLOW_CREDENTIALS = <span class="literal">True</span></span><br><span class="line">CORS_ORIGIN_ALLOW_ALL = <span class="literal">True</span></span><br><span class="line">CORS_ORIGIN_WHITELIST = (</span><br><span class="line">	<span class="string">'*'</span></span><br><span class="line">)</span><br><span class="line">CORS_ALLOW_METHODS = (</span><br><span class="line">	<span class="string">'DELETE'</span>,</span><br><span class="line">	<span class="string">'GET'</span>,</span><br><span class="line">	<span class="string">'OPTIONS'</span>,</span><br><span class="line">	<span class="string">'PATCH'</span>,</span><br><span class="line">	<span class="string">'POST'</span>,</span><br><span class="line">	<span class="string">'PUT'</span>,</span><br><span class="line">	<span class="string">'VIEW'</span>,</span><br><span class="line">)</span><br><span class="line"></span><br><span class="line">CORS_ALLOW_HEADERS = (</span><br><span class="line">	<span class="string">'XMLHttpRequest'</span>,</span><br><span class="line">	<span class="string">'X_FILENAME'</span>,</span><br><span class="line">	<span class="string">'accept-encoding'</span>,</span><br><span class="line">	<span class="string">'authorization'</span>,</span><br><span class="line">	<span class="string">'content-type'</span>,</span><br><span class="line">	<span class="string">'dnt'</span>,</span><br><span class="line">	<span class="string">'origin'</span>,</span><br><span class="line">	<span class="string">'user-agent'</span>,</span><br><span class="line">	<span class="string">'x-csrftoken'</span>,</span><br><span class="line">	<span class="string">'x-requested-with'</span>,</span><br><span class="line">	<span class="string">'Pragma'</span>,</span><br><span class="line">)</span><br></pre></td></tr></table></figure></section>
    <!-- Tags START -->
    
    <!-- Tags END -->
    <!-- NAV START -->
    
  <div class="nav-container">
    <!-- reverse left and right to put prev and next in a more logic postition -->
    
      <a class="nav-left" href="/python/%E8%B7%AF%E9%A3%9E%E9%A1%B9%E7%9B%AE/1-%E9%A1%B9%E7%9B%AE%E5%9F%BA%E7%A1%80/0-%E8%B7%AF%E9%A3%9E%E5%AD%A6%E5%9F%8E/">
        <span class="nav-arrow">← </span>
        
          python/路飞项目/1-项目基础/0-路飞学城
        
      </a>
    
    
      <a class="nav-right" href="/python/%E5%85%B6%E4%BB%96/07-ZeroRPC%E5%92%8CSimpleXMLRPCServer/">
        
          python/其他/07-ZeroRPC和SimpleXMLRPCServer
        
        <span class="nav-arrow"> →</span>
      </a>
    
  </div>

    <!-- NAV END -->
    <!-- 打赏 START -->
    
      <div class="money-like">
        <div class="reward-btn">
          赏
          <span class="money-code">
            <span class="alipay-code">
              <div class="code-image"></div>
              <b>使用支付宝打赏</b>
            </span>
            <span class="wechat-code">
              <div class="code-image"></div>
              <b>使用微信打赏</b>
            </span>
          </span>
        </div>
        <p class="notice">点击上方按钮,请我喝杯咖啡！</p>
      </div>
    
    <!-- 打赏 END -->
    <!-- 二维码 START -->
    
      <div class="qrcode">
        <canvas id="share-qrcode"></canvas>
        <p class="notice">扫描二维码，分享此文章</p>
      </div>
    
    <!-- 二维码 END -->
    
      <!-- Gitment START -->
      <div id="comments"></div>
      <!-- Gitment END -->
    
  </article>
  <!-- Article END -->
  <!-- Catalog START -->
  
    <aside class="catalog-container">
  <div class="toc-main">
  <!-- 不蒜子统计 -->
    <strong class="toc-title">目录</strong>
    
      <ol class="toc-nav"><li class="toc-nav-item toc-nav-level-1"><a class="toc-nav-link" href="#跨域请求"><span class="toc-nav-text">跨域请求</span></a><ol class="toc-nav-child"><li class="toc-nav-item toc-nav-level-2"><a class="toc-nav-link" href="#一-同源策略"><span class="toc-nav-text">一 同源策略</span></a></li><li class="toc-nav-item toc-nav-level-2"><a class="toc-nav-link" href="#二-CORS（跨域资源共享）简介"><span class="toc-nav-text">二 CORS（跨域资源共享）简介</span></a></li><li class="toc-nav-item toc-nav-level-2"><a class="toc-nav-link" href="#三-CORS基本流程"><span class="toc-nav-text">三 CORS基本流程</span></a></li><li class="toc-nav-item toc-nav-level-2"><a class="toc-nav-link" href="#四-CORS两种请求详解"><span class="toc-nav-text">四 CORS两种请求详解</span></a></li><li class="toc-nav-item toc-nav-level-2"><a class="toc-nav-link" href="#五-Django项目中支持CORS"><span class="toc-nav-text">五 Django项目中支持CORS</span></a></li><li class="toc-nav-item toc-nav-level-2"><a class="toc-nav-link" href="#六-django-使用django-cors-headers-解决跨域问题"><span class="toc-nav-text">六 django 使用django-cors-headers 解决跨域问题</span></a><ol class="toc-nav-child"><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#1、使用pip安装"><span class="toc-nav-text">1、使用pip安装</span></a></li><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#2、添加到setting的app中"><span class="toc-nav-text">2、添加到setting的app中</span></a></li><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#3、添加中间件"><span class="toc-nav-text">3、添加中间件</span></a></li><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#4、setting下面添加下面的配置"><span class="toc-nav-text">4、setting下面添加下面的配置</span></a></li></ol></li></ol></li></ol>
    
  </div>
</aside>
  
  <!-- Catalog END -->
</main>

<script>
  (function () {
    var url = 'http://www.liuqingzheng.top/python/路飞项目/1-项目基础/15-跨域请求详解/';
    var banner = ''
    if (banner !== '' && banner !== 'undefined' && banner !== 'null') {
      $('#article-banner').css({
        'background-image': 'url(' + banner + ')'
      })
    } else {
      $('#article-banner').geopattern(url)
    }
    $('.header').removeClass('fixed-header')

    // error image
    $(".markdown-content img").on('error', function() {
      $(this).attr('src', 'http://file.muyutech.com/error-img.png')
      $(this).css({
        'cursor': 'default'
      })
    })

    // zoom image
    $(".markdown-content img").on('click', function() {
      var src = $(this).attr('src')
      if (src !== 'http://file.muyutech.com/error-img.png') {
        var imageW = $(this).width()
        var imageH = $(this).height()

        var zoom = ($(window).width() * 0.95 / imageW).toFixed(2)
        zoom = zoom < 1 ? 1 : zoom
        zoom = zoom > 2 ? 2 : zoom
        var transY = (($(window).height() - imageH) / 2).toFixed(2)

        $('body').append('<div class="image-view-wrap"><div class="image-view-inner"><img src="'+ src +'" /></div></div>')
        $('.image-view-wrap').addClass('wrap-active')
        $('.image-view-wrap img').css({
          'width': `${imageW}`,
          'transform': `translate3d(0, ${transY}px, 0) scale3d(${zoom}, ${zoom}, 1)`
        })
        $('html').css('overflow', 'hidden')

        $('.image-view-wrap').on('click', function() {
          $(this).remove()
          $('html').attr('style', '')
        })
      }
    })
  })();
</script>


  <script>
    var qr = new QRious({
      element: document.getElementById('share-qrcode'),
      value: document.location.href
    });
  </script>



  <script>
    var gitmentConfig = "liuqingzheng";
    if (gitmentConfig !== 'undefined') {
      var gitment = new Gitment({
        id: "python/路飞项目/1-项目基础/15-跨域请求详解",
        owner: "liuqingzheng",
        repo: "FuckBlog",
        oauth: {
          client_id: "32a4076431cf39d0ecea",
          client_secret: "94484bd79b3346a949acb2fda3c8a76ce16990c6"
        },
        theme: {
          render(state, instance) {
            const container = document.createElement('div')
            container.lang = "en-US"
            container.className = 'gitment-container gitment-root-container'
            container.appendChild(instance.renderHeader(state, instance))
            container.appendChild(instance.renderEditor(state, instance))
            container.appendChild(instance.renderComments(state, instance))
            container.appendChild(instance.renderFooter(state, instance))
            return container;
          }
        }
      })
      gitment.render(document.getElementById('comments'))
    }
  </script>




    <div class="scroll-top">
  <span class="arrow-icon"></span>
</div>
    <footer class="app-footer">
<!-- 不蒜子统计 -->
<span id="busuanzi_container_site_pv">
     本站总访问量<span id="busuanzi_value_site_pv"></span>次
</span>
<span class="post-meta-divider">|</span>
<span id="busuanzi_container_site_uv" style='display:none'>
     本站访客数<span id="busuanzi_value_site_uv"></span>人
</span>
<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>



  <p class="copyright">
    &copy; 2021 | Proudly powered by <a href="https://www.cnblogs.com/xiaoyuanqujing" target="_blank">小猿取经</a>
    <br>
    Theme by <a href="https://www.cnblogs.com/xiaoyuanqujing" target="_blank" rel="noopener">小猿取经</a>
  </p>
</footer>

<script>
  function async(u, c) {
    var d = document, t = 'script',
      o = d.createElement(t),
      s = d.getElementsByTagName(t)[0];
    o.src = u;
    if (c) { o.addEventListener('load', function (e) { c(null, e); }, false); }
    s.parentNode.insertBefore(o, s);
  }
</script>
<script>
  async("//cdnjs.cloudflare.com/ajax/libs/fastclick/1.0.6/fastclick.min.js", function(){
    FastClick.attach(document.body);
  })
</script>

<script>
  var hasLine = 'true';
  async("//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js", function(){
    $('figure pre').each(function(i, block) {
      var figure = $(this).parents('figure');
      if (hasLine === 'false') {
        figure.find('.gutter').hide();
      }
      var lang = figure.attr('class').split(' ')[1] || 'code';
      var codeHtml = $(this).html();
      var codeTag = document.createElement('code');
      codeTag.className = lang;
      codeTag.innerHTML = codeHtml;
      $(this).attr('class', '').empty().html(codeTag);
      figure.attr('data-lang', lang.toUpperCase());
      hljs.highlightBlock(block);
    });
  })
</script>





<!-- Baidu Tongji -->

<script>
    var _baId = 'c5fd96eee1193585be191f318c3fa725';
    // Originial
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "//hm.baidu.com/hm.js?" + _baId;
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
</script>


<script src="/js/script.js"></script>


<script src="/js/search.js"></script>


<script src="/js/load.js"></script>



  <span class="local-search local-search-google local-search-plugin" style="right: 50px;top: 70px;;position:absolute;z-index:2;">
      <input type="search" placeholder="站内搜索" id="local-search-input" class="local-search-input-cls" style="">
      <div id="local-search-result" class="local-search-result-cls"></div>
  </span>


  </body>
</html>